package org.tinygroup.bizframe.common.impl;

import org.tinygroup.bizframe.common.AuditLogger;
import org.tinygroup.logger.LogLevel;
import org.tinygroup.logger.Logger;
import org.tinygroup.logger.LoggerFactory;

public class DefaultAuditLogger implements AuditLogger {

	
	private final static Logger logger = LoggerFactory.getLogger(DefaultAuditLogger.class);
	
	public void logData(String userId, Object datas) {
		if(datas instanceof Object[]){
			Object[] objs = (Object[])datas;
			StringBuilder msg = new StringBuilder("[AuditLogger]userId:"+userId+" datas: {0}:"); 
			for (Object obj : objs) {
				msg.append(",{}");
			}
			logger.warnMessage(msg.toString(), objs);
		}
		else{
		    logger.logMessage(LogLevel.WARN, "[AuditLogger]userId:"+userId+" datas: {0}:",datas);
		}
	}

}
